package de.baumann.browser.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import de.baumann.browser.R

class CardPowerAdapter(var context: Context, private var powers:List<String>,private var textColor:Int) : RecyclerView.Adapter<CardPowerAdapter.PowerHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PowerHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_power, parent, false)
        return PowerHolder(view)
    }

    override fun getItemCount(): Int {
        return powers.size
    }

    override fun onBindViewHolder(holder: PowerHolder, position: Int) {
        holder.power.text = powers[position]
        holder.power.setTextColor(context.resources.getColor(textColor))
    }

    inner class PowerHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var power: TextView = itemView.findViewById(R.id.power)
    }
}